#include <thread>
#include "threadlock.h"
#include <iostream>
#include <atomic>
#include <Windows.h>
#include <mutex>
std::atomic<int> anum = 0;
std::string c;
template<typename T>
void startthread(threadlock<T> a) {
	T b = a;
	std::cout << b << std::endl;
	/*
	c += std::string(a);
	anum++;
	*/
}
void testthread(char* a) {
	c += std::string(a);
	anum++;
}
int main() {
	/*
	char tmp[] = "w";
	char* tmpptr = tmp;
	threadlock<char*> b = tmpptr;
	double start = GetTickCount();
	*/
	double a = 2;
	threadlock<double> b = a;
	for (int i = 0; i < 500; i++) {
		std::thread a(startthread<double>, b);
		a.detach();
	}
	/*
	while (anum < 500) {};
	double  end = GetTickCount();
	std::cout << "GetTickCount:" << end - start << std::endl;
	anum = 0;
	start = GetTickCount();
	for (int i = 0; i < 500; i++) {
		std::thread a(testthread, tmpptr);
		a.detach();
	}
	while (anum < 500) {};
	end = GetTickCount();
	std::cout << "GetTickCount:" << end - start << std::endl;
	*/

}